﻿;(function($){

	$.jgrid.extend({
		/**
		 * 根据id,批量的将新增或修改过的数据回复
		 */
		restoreRowDataByIds : function(ids){
			var grid = this[0],_this = this;
			for(var r = ids.length-1; r>=0; r--){
				var rowId = ids[r];
				var rowObj = _this.jqGrid("getRowDataById",rowId);
				//1、如果是新增的数据将清空
				if(rowObj.rowStatus == Gfa.GlobalConstant.ROWSTATUS_ADDED){
					_this.jqGrid('deleteRowById', rowId);
				}else{
					//2.如果其它状态的数据,将还原到查询时候的数据
					for(var i=0;i<grid.p.originalDatas.list.length;i++){
						var originalData = grid.p.originalDatas.list[i];
						if($.jgrid.getAccessor(originalData,grid.p.jsonReader.id)==rowId){
							//解决将日期按formatoptions中的格式进行格式化[取消会导致时间YYYY-MM-DD 回复到YYYY-MM-DD HH:MI:SS]
							for(var j=0;j<grid.p.colModel.length;j++){
								var cm = grid.p.colModel[j];
								if(cm.formatter && cm.formatter==='date' && cm.formatoptions) {
									var opts= {rowId: rowId, colModel:cm, gid:grid.p.id, pos:j };
									v = $.fn.fmatter.call(_this,cm.formatter,originalData[cm.name],opts,originalData,"add");
									originalData[cm.name] = v;
								} 
							}
							//将gridDatasStore的数据也要同时回复
							var gridDatasStoreRowData = _this.jqGrid("getGridDatasStoreById",rowId);
							//并回复行数据
							_this.jqGrid("setRowData",rowId,$.extend({},gridDatasStoreRowData,originalData))
						}
					}
				}
			}
		},
		/**
		 * 根据Id删除行数据
		 */
		deleteRowById : function(rowId){
			var grid = this[0],_this = this;
			//1.取消其它行选中
			_this.jqGrid('resetSelection');
			//2.选中当前行
			_this.jqGrid("setSelection",rowId,true);
			var editData = [];
			editData[0] = _this.jqGrid("getRowDataById",rowId);
			//判断行状态为新增时,直接删除
			if(editData[0].rowStatus == Gfa.GlobalConstant.ROWSTATUS_ADDED){
				_this.jqGrid('delRowData', rowId);
				_this.jqGrid('delGridDatasStoreById', rowId);
				return;
			}
			editData[0].rowStatus = Gfa.GlobalConstant.ROWSTATUS_DELETED;
			_this.jqGrid("deleteRows",editData);
		},
		/**
		 * 删除数据集
		 */
		deleteRows : function(editData){
			var grid = this[0],_this = this;
			//1.删除前方法
			if(grid.p.beforeDelete){
				if(!(grid.p.beforeDelete.call(grid,editData))){
					return false;
				}
			}
			//2.根据列的 originalDataType 转换数据类型
			_this.jqGrid('convertToOriginalDataType',editData);
			
			//3.选择行对话框
			if(editData && editData.length < 1){
				$.ui.dialog4Prompt($.jgrid.prompt.selectDel);
				return;
			}else{
//				var deleteSelectRow = function(){
//					if(editData.length < 1)return;
//					var dwrOption = {
//						callback:function(result){
//							//5.删除后方法
//							if($.isFunction(grid.p.afterDelete)){
//								grid.p.afterDelete.call(grid,result);
//							}else{
//								//内置删除成功提示
//								$("#"+grid.p.id+"MessageDialog").html($.jgrid.success.del)
//									.dialog("option","title", $.jgrid.initMessageTag.deleteSuccessTag)
//									.dialog("open");
//							}
//							//6.重载数据
//							_this.jqGrid("reloadGrid");
//							//7.清空编辑区
//							$(grid.p.editFormSelector).trigger("reset");
//						}
//					}
//					eval(grid.p.serviceName)[grid.p.serviceMethodName](editData,$.DwrUtils.proDwrOption(dwrOption));
//				}
				//4.确认删除对话框
//				var imgUrl = "<img src='"+App.ctx+"/scripts/widgets/jquery-ui/extend/images/icon-question.gif'/>";
//				$("<div>").attr('title',$.jgrid.nav.alertcap).html(imgUrl+" "+$.jgrid.del.msg).dialog({
//					modal:true,
//					height:200,
//					resizable:false,
//					show:$.ui.effects.dialog.show,
//					hide:$.ui.effects.dialog.hide,
//					buttons:[
//					    {"text":$.jgrid.del.bSubmit,
//						"click":function(){
//							deleteSelectRow();
//							$(this).dialog("close");
//						}},
//						{"text":$.jgrid.del.bCancel,
//						"click":function(){
//							$(this).dialog("close");
//						}}
//					]
//				});
				_this.jqGrid("messageDialog",editData);
			}
			
		},
		/**
		 * 获取选中行的id,返回[]
		 */
		getSelectRowIds : function(){
			var grid = this[0],_this = this,ids = [];
			//不允许多行选中时,取当前选中行
			if(!grid.p.multiselect){
				var selrow = _this.jqGrid('getGridParam','selrow');
				if(selrow!=null && selrow.length>0){
					ids[0] = selrow;
				}
			}else{
				ids = _this.jqGrid('getGridParam','selarrrow');
			}
			return ids;
		},
		/**
		 * 根据单个Id获取行数据,返回{}
		 */
		getRowDataById : function(rowId){
			var grid = this[0],_this = this;
			var regExp = /<input|<select|<textarea/gi;

			var rowData = _this.jqGrid('getRowData',rowId);
			if(grid.p.actionColNames.length>0){
				for(var proName in rowData){
					//将动作列数据处理掉
					for (var ac=0;ac<grid.p.actionColNames.length;ac++) {
						if(proName == grid.p.actionColNames[ac]){
							delete rowData[proName];
						}
					}
					//验证是否存在html代码的数据
					var flag = regExp.test(rowData[proName]);
					if(flag){
						//获取实际的数据<input value=123>,<select><option selected=selected value=123>456</option></select>,<textarea>123</textarea>
						var $elm = $(rowData[proName]);
						if($elm.is("input") || $elm.is("select") || $elm.is("textarea")){
							rowData[proName] = $elm.val();
						}else{
							alert("Exception data : "+proName+" : "+rowData[proName]);
						}
					}
				}
			}
			//将grid的实际数据存储,与grid 上获取到的数据合并
			var gridData = _this.jqGrid("getGridDatasStoreById",rowId);
			//
//			alert($.objToJSONString($.extend({},gridData,rowData)));
			return $.extend({},gridData,rowData);
		},
		/**
		 * 根据多Id获取行数据,返回[]
		 */
		getRowDataByIds : function(ids){
			var _this = this;
			var editData = [];
			for(var i=0;i<ids.length;i++){
				editData.push(_this.jqGrid('getRowDataById',ids[i]));
			}
			return editData;
		},
		/**
		 * 获取所有行数据,返回[]
		 */
		getAllRowDatas : function(){
			var grid = this[0],_this = this;
			var ids = _this.jqGrid('getDataIDs');
			var editDatas = _this.jqGrid('getRowDataByIds',ids);
			return editDatas;
		},
		/**
		 * 获取选中的行数据,返回[]
		 */
		getRowDatasBySelect : function(){
			var grid = this[0],_this = this;
			
			//1.不允许多行选中时,取当前选中行
			ids = _this.jqGrid("getSelectRowIds");
			var editDatas = _this.jqGrid('getRowDataByIds',ids);
			return editDatas;
		},
		/**
		 * 获取被修改的行数据(新增,修改),返回[]
		 */
		getRowDatasByModified : function(){
			var grid = this[0],_this = this;
			var rowIds = _this.jqGrid('getRowIdsByModified');
			//1.收集到被修改的数据
			var editDatas = [];
			for(var i=0;i<rowIds.length;i++){
				var rowId = rowIds[i];
				editDatas.push(_this.jqGrid('getRowDataById',rowId));
			}
			return editDatas;
		},
		/**
		 * 获取被修改的行Id(新增,修改),返回[]
		 */
		getRowIdsByModified : function(){
			var grid = this[0],_this = this;
			//var rowObjs = _this.jqGrid('getAllRowDatas');
			//获取实际grid的store, 
			var rowObjs = grid.p.gridDatasStore;
			
			//1.收集到被修改的数据id
			var ids = [];
			for(var i=0;i<rowObjs.length;i++){
				var rowObj = rowObjs[i];
				if(rowObj.rowStatus == Gfa.GlobalConstant.ROWSTATUS_MODIFIED || rowObj.rowStatus == Gfa.GlobalConstant.ROWSTATUS_ADDED){
					ids.push(rowObj[grid.p.jsonReader.id]);
				}
			}
			return ids;
		},
		/**
		 * 获取所有要删除数据
		 */
		getRowDatasByDelete : function(){
			var _this = this,grid = this[0],ids = [];
			ids = _this.jqGrid("getSelectRowIds");
			var editData = [];
			for(var i=0;i<ids.length;i++){
				var rowObj = _this.jqGrid('getRowDataById',ids[i]);
				//判断行状态为新增时,直接删除
				if(rowObj.rowStatus == Gfa.GlobalConstant.ROWSTATUS_ADDED){
					_this.jqGrid('delRowData', ids[i]);
					continue;
				}
				rowObj.rowStatus = Gfa.GlobalConstant.ROWSTATUS_DELETED;
				editData.push(rowObj);
			}
			return editData;
		},
		/**
		 * 获取Grid的行ID命名
		 */
		getGridRowIdName : function(){
			var grid = this[0],_this = this;
			return grid.p.jsonReader.id;
		},
		/**
		 * 给Grid的queryInfo追加查询条件
		 */
		setQueryInfoFields : function (fields){
			var grid = this[0];
			grid.p.customFields = fields;
		},
		/**
		 * 转换成原始数据类型
		 */
		convertToOriginalDataType : function(datas){
			var _this = this,grid = this[0],originalDataTypes = grid.p.cmOriginalDataType;
			if($.isPlainObject(originalDataTypes) && !$.isEmptyObject(originalDataTypes)){
				for(var i = 0; i < datas.length; i++){
					$.jgrid.convertDataType(datas[i],originalDataTypes);	
				}
			}
			return datas;
		},
		/**
		 * 重载grid
		 */
		reloadGrid : function(){
			var grid = this[0],_this = this;
			//1.激活加载
			grid.p.enabledLoad = true;
			this.trigger("reloadGrid");
			//2.同时刷新子表
			$.jgrid.reloadSubGrids(grid.p.subGridMaps);
			//3.重置一下宽度
			_this.jqGrid("resetGridWidth",true);
			//4.表格内编辑需要重置一下"行列"坐标,和最新选中行
			if(grid.p.cellEdit === true){
				grid.p.iRow = -1;
				grid.p.iCol = -1;
				grid.p.selrow = "";
			}
		},
		/**
		 * 重新调整宽度
		 */
		resetGridWidth : function(resetFlag,fixWidth){
			var grid = this[0],_this = this;
			if(!grid.p.onceResetWidth || resetFlag === true){
				
				var $divPageLoadComplete = $("#pageLoadComplete");
				
				function setWidth(_fixWidth){
					//3.divPageLoadComplete 的属性complete=true 时,表示页面加载完成
	    	    	if($divPageLoadComplete.attr('isComplete')=="true" || $divPageLoadComplete.attr('isComplete')===true){
	    	    		var _parentWidth = parseInt($('#gbox_'+grid.p.id).parent().css("width"))*1;
	    	    		//alert("id = "+grid.p.id+",宽度"+_parentWidth);
	    	    		if(grid.p.autowidth === true){
	    					//2.调方法设置宽度
	    					if ($.browser.msie && $.browser.version <= 7){
								//parentWidth是在grid.layout.js 里存入的
	    						_parentWidth = $('#'+grid.p.id).attr('parentWidth');
	    					}
//	    					alert("_fixWidth = "+_fixWidth+" , _parentWidth = "+_parentWidth);
	    					if(_fixWidth && _fixWidth>0){
	    						_this.jqGrid('setGridWidth',_fixWidth-20);
	    					}else{
	    						_this.jqGrid('setGridWidth',_parentWidth-20);
	    					}
	    				}else{
	    					if ($.browser.msie && $.browser.version <= 7){
								//parentWidth是在grid.layout.js 里存入的
	    						_parentWidth = $('#'+grid.p.id).attr('parentWidth');
	    					}
	    					if(_fixWidth && _fixWidth>0){
	    						_parentWidth = _fixWidth;
	    					}
    						$('#gbox_'+grid.p.id).css({"width":_parentWidth-20});
    						$('#gview_'+grid.p.id).css({"width":_parentWidth-20});
    						$(".ui-jqgrid-hdiv",'#gview_'+grid.p.id).css({"width":_parentWidth-20});
    						$(".ui-jqgrid-bdiv",'#gview_'+grid.p.id).css({"width":_parentWidth-20});
    						$('#'+grid.p.id+'_toppager').css({"width":_parentWidth-20});
    						$('#'+grid.p.id+'_pager').css({"width":_parentWidth-20});
	    				}
	    	    		//5.回收时间轮询对象
	    	    		window.clearInterval(gridSetWidthIntervalObj);
	    	    	}
				}
				var gridSetWidthIntervalObj = window.setInterval(function(){setWidth(fixWidth);},100);
				
				//3.grid宽度已经调整标识
				grid.p.onceResetWidth = true;
			}
		},
		/**
		 * 打开editWindow
		 */
		openEditWindow : function(){
			var grid = this[0],_this = this;
			if ($.isPlainObject(grid.p.editWindow) && !$.isEmptyObject(grid.p.editWindow)) {
				$.jqValidator.setIsShowValidateMsg(grid.p.editFormSelector, true);
				var $editWindow = $(grid.p.editWindow.selector);
				if($editWindow){
					$editWindow.dialog("open");
				}
				var rowid = grid.p.selrow;
				if (rowid) {
					//确保弹出层先打开后，再执行赋值动作	
					grid.p.enabledValidateForm = true;
					_this.jqGrid('GridToForm', rowid, grid.p.editFormSelector);
				}
			}
		},
		/**
		 * 获取grid 的所有列名称(隐藏与显示)
		 */
		getAllColNames : function(){
			var grid = this[0],_this = this,colNames = [];
			for(var i=0;i<grid.p.colModel.length;i++){
				if(grid.p.colModel[i].actionType == undefined || grid.p.colModel[i].actionType.length < 1){
					//排除 复选列/行码列
					if(grid.p.colModel[i].name && grid.p.colModel[i].name.length>0 && grid.p.colModel[i].name!="rn" && grid.p.colModel[i].name!="cb")
						colNames.push(grid.p.colModel[i].name);
				}
			}
			return colNames;
		},
		/**
		 * 获取grid 的所有显示列名称
		 */
		getShowColNames : function(){
			var grid = this[0],_this = this,colNames = [];
			for(var i=0;i<grid.p.colModel.length;i++){
				if(grid.p.colModel[i].hidden != true){
					if(grid.p.colModel[i].actionType == undefined || grid.p.colModel[i].actionType.length < 1){
						//排除 复选列/行码列 
						if(grid.p.colModel[i].name && grid.p.colModel[i].name.length>0 && grid.p.colModel[i].name!="rn" && grid.p.colModel[i].name!="cb")
							colNames.push(grid.p.colModel[i].name);
					}
				}
			}
			return colNames;
		},
		/**
		 * 获取grid 的所有隐藏列名称
		 */
		getHiddenColNames : function(){
			var grid = this[0],_this = this,colNames = [];
			for(var i=0;i<grid.p.colModel.length;i++){
				if(grid.p.colModel[i].hidden === true){
					if(grid.p.colModel[i].actionType == undefined || grid.p.colModel[i].actionType.length < 1){
						//排除 复选列/行码列
						if(!$.StringUtils.isEmpty(grid.p.colModel[i].name) && grid.p.colModel[i].name!="rn" && grid.p.colModel[i].name!="cb")
							colNames.push(grid.p.colModel[i].name);
					}
				}
			}
			return colNames;
		},
		/**
		 * 获取grid 的所有列标题(隐藏与显示)
		 */
		getAllColLabels : function(){
			var grid = this[0],_this = this,colLabels = [];
			for(var i=0;i<grid.p.colModel.length;i++){
				if(grid.p.colModel[i].actionType == undefined || grid.p.colModel[i].actionType.length < 1){
					if(grid.p.colModel[i].label && grid.p.colModel[i].label.length>0)
						colLabels.push(grid.p.colModel[i].label);
				}
			}
			return colLabels;
		},
		/**
		 * 获取grid 的所有显示列标题
		 */
		getShowColLabels : function(){
			var grid = this[0],_this = this,colLabels = [];
			for(var i=0;i<grid.p.colModel.length;i++){
				if(grid.p.colModel[i].hidden != true){
					if(grid.p.colModel[i].actionType == undefined || grid.p.colModel[i].actionType.length < 1){
						if(grid.p.colModel[i].label && grid.p.colModel[i].label.length>0)
							colLabels.push(grid.p.colModel[i].label);
					}
				}
			}
			return colLabels;
		},
		/**
		 * 获取grid 的所有隐藏列标题
		 */
		getHiddenColLabels : function(){
			var grid = this[0],_this = this,colLabels = [];
			for(var i=0;i<grid.p.colModel.length;i++){
				if(grid.p.colModel[i].hidden === true){
					if(grid.p.colModel[i].actionType == undefined || grid.p.colModel[i].actionType.length < 1){
						if(grid.p.colModel[i].label && grid.p.colModel[i].label.length>0)
							colLabels.push(grid.p.colModel[i].label);
					}
				}
			}
			return colLabels;
		},
		/**
		 * 保存grid的数据
		 */
		saveGridDatas : function(){
			var grid = this[0],_this = this;
			//1.如果启用表格内编辑，需要恢复正在编辑的单元格到不可编辑状态
			_this.jqGrid("restoreCellStatus");
			//2.获处理好的数据
			var editDatas = _this.jqGrid("getPrepareRowDatas");
			if(editDatas.length < 1)return;
			//3.保存前方法
			if(grid.p.beforeSave){
				if(!(grid.p.beforeSave.call(grid,editDatas))){
					return false;
				}
			}
			//表格内编辑的校验
			if(!_this.jqGrid("validateCellDatas",_this.jqGrid("getSaveRowDatas"))){
				return false;
			}
			//4.验证表单
			if(grid.p.enabledValidateForm && !$.jqValidator.validateForm(grid.p.editFormSelector)){
				return false;
			}
			//5.保存option 定义
			var dwrOption = {
				callback:function(result){
					//6.保存后方法
					if($.isFunction(grid.p.afterSave)){
						grid.p.afterSave.call(grid,result);
					}else{
						//内置保存成功提示
						$("#"+grid.p.id+"MessageDialog")
							.html($.jgrid.success.save)
							.dialog("option","title", $.jgrid.initMessageTag.saveSuccessTag)
							.dialog("open");
					}
					//7.重载
					_this.jqGrid("reloadGrid");
					//8.清楚编辑表单数据
					$(grid.p.editFormSelector).trigger("reset");
					//9.屏蔽验证
					grid.p.enabledValidateForm = false;
					//按钮状态
					_this.jqGrid('refreshButtonStatus');
				}
			}
			if(grid.p.saveError && $.isFunction(grid.p.saveError)){
				$.extend(dwrOption,{
					errorHandler : function(message){
						grid.p.saveError.call(grid,message);
					},
					exceptionHandler : function(message){
						grid.p.saveError.call(grid,message);
					}
				});
			}
			eval(grid.p.serviceName)[grid.p.serviceMethodName](editDatas,$.DwrUtils.proDwrOption(dwrOption));
		},
		/**
		 * 如果启用表格内编辑，需要恢复正在编辑的单元格到不可编辑状态
		 */
		restoreCellStatus : function(){
			var grid = this[0],_this = this;
			if(grid.p.cellEdit === true){
				// 如果已经有正在编辑的单元格必须先保存
				if (grid.p.savedRow.length > 0 && grid.p.iRow>0 && grid.p.iCol>0) {
					_this.jqGrid("saveCell", grid.p.iRow,grid.p.iCol);
				}
			}
		},
		/**
		 * 设置url动态改变查询地址
		 */
		setUrl : function(newUrl){
			var grid = this[0];
			grid.p.url = newUrl;
		},
		/**
		 * 提交自定义参数
		 * maps: [{paramName1:"value"},{paramName2:"value2"}...]
		 */
		addPostData : function(maps){
			var grid = this[0];
			if($.isArray(maps) && maps.length>0){
				for(var i=0;i<maps.length;i++){
					for(var key in maps[i]){
						grid.p.postData[key] = maps[i][key];
					}
				}
			}
//			alert($.objToJSONString(grid.p.postData));
		},
		/**
		 * 获取当前最新选中的行ID值
		 */
		getCurrentSelectRowId : function(){
			var grid = this[0];
			return grid.p.selrow;
		},
		/**
		 * 获取当前最新选中的行数据
		 */
		getCurrentSelectRowData : function(){
			var grid = this[0],_this = this;
			return _this.jqGrid("getRowDataById",_this.jqGrid("getCurrentSelectRowId"));
		},
		/**
		 * 获取grid 每页显示记录数
		 */
		getPageSize : function(){
			var grid = this[0];
			return grid.p.postData.rows;
		},
		/**
		 * 获取grid 的最后页码
		 */
		getLastPage:function(){
			var grid = this[0];
			var count = grid.p.records, pageSize = this.getPageSize();
			if(count == 0) return 0;
			return Math.ceil(count / pageSize);
		},
		/**
		 * 获取grid 的当前起始页码
		 */
		getPageStart : function(){
			var grid = this[0],pageStart = 1, lastpage = this.getLastPage();
			if(grid.p.page > lastpage && lastpage > 0){
				pageStart = (lastpage - 1) * grid.p.postData.rows + 1;
			}else{
				pageStart = (grid.p.page - 1) * grid.p.postData.rows + 1;
			}
//			alert("grid.p.page = "+grid.p.page);
			return pageStart;
		},
		/**
		 * 获取grid 的queryInfo
		 */
		getQueryInfo : function(){
			var grid = this[0],_this = this;
			var _queryInfo = {
				"pageSize" : _this.jqGrid("getPageSize"),
				"pageStart" : _this.jqGrid("getPageStart")
			};
			return $.extend({},$.parseJSON(grid.p.postData.queryInfo),_queryInfo);
		},
		/**
		 * 获取列Model
		 */
		getAllColModel : function(){
			var grid = this[0];
			return grid.p.colModel;
		},
		/**
		 * 根据下标获取列Model
		 */
		getColModelByIndex : function(index){
			var grid = this[0];
			return grid.p.colModel[index];
		},
		/**
		 * 根据name获取列Model
		 */
		getColModelByName : function(name){
			var grid = this[0],col = [];
			for(var i=0;i<grid.p.colModel.length;i++){
				if (grid.p.colModel[i].name === name) {
					col = grid.p.colModel[i];
					break;
				}
			}
			return col;
		},
		/**
		 * 设置表格属性(对于部分属性设置后,会对grid起到作用,不是全部属性都可以动态设置)
		 * 例如：
		 * 	动态关闭表格内编辑{"cellEdit":false}
		 * 	动态设置每页记录数{"rowNum":18}
		 */
		setGridAttribute : function(attributeConfig){
			var grid = this[0];
			$.extend(grid.p,attributeConfig);
		},
		/**
		 * 校验表格内编辑的单元格数据校验
		 * 当cellEdit = true时才生效
		 */
		validateCellDatas : function(datas){
			var grid = this[0],_this = this;
			//验证结果
			var allValuedateResultArr = [],valuedateResult = true;
			if(grid.p.cellEdit === true){
				//变量数据
				for(var d=0;d<datas.length;d++){
					var rowData = datas[d];
					//取到数据 属性名称
					for(var propertyName in rowData){
						for(var cm=0;cm<grid.p.colModel.length;cm++){
							var subColModel = grid.p.colModel[cm];
							//判断当前属性(列)，是否有配置校验规则
							if(propertyName == subColModel.name && !$.isEmptyObject(subColModel.editrules)){
								var propertyVal = rowData[propertyName];
								//执行校验
								var validateResultArr = $.jgrid.validateCellValues(propertyVal,cm,grid);
								allValuedateResultArr.push(validateResultArr);
								break;
							}else{
								continue;
							}
						}
					}
				}
			}
			//组织校验信息
			var allValuedateResultMsg = "";
			for(var i=0;i<allValuedateResultArr.length;i++){
				var _valuedateResultArr = allValuedateResultArr[i];
				if(!_valuedateResultArr[0]){
					valuedateResult=false;
					allValuedateResultMsg += _valuedateResultArr[1]+"</br>";
				}
			}
			//弹出层显示校验信息
			if(!valuedateResult){
				var imgUrl = "<img src='"+App.ctx+"/scripts/widgets/jquery-ui/extend/images/icon-warning.gif'/>";
				$('<div>').attr('title',i18n.message.warning).html(imgUrl+"</br>"+allValuedateResultMsg).dialog({
					modal:true,
					resizable:$.ui.effects.dialog.resizable,
					show:$.ui.effects.dialog.show,
					hide:$.ui.effects.dialog.hide,
					buttons:[{
						"text":i18n.global.close,
						"click":function(){
							$(this).dialog("close");
						}
					}]
				});
			}
			//返回校验结果
			return valuedateResult;
		},
		messageDialog:function(editData){
			var grid = this[0],_this = this;
//			var deleteSelectRow = function(){
//				if(editData.length < 1)return;
//				var dwrOption = {
//					callback:function(result){
//						//5.删除后方法
//						if($.isFunction(grid.p.afterDelete)){
//							grid.p.afterDelete.call(grid,result);
//						}else{
//							//内置删除成功提示
//							$("#"+grid.p.id+"MessageDialog").html($.jgrid.success.del)
//								.dialog("option","title", $.jgrid.initMessageTag.deleteSuccessTag)
//								.dialog("open");
//						}
//						//6.重载数据
//						_this.jqGrid("reloadGrid");
//						//7.清空编辑区
//						$(grid.p.editFormSelector).trigger("reset");
//					}
//				}
//				eval(grid.p.serviceName)[grid.p.serviceMethodName](editData,$.DwrUtils.proDwrOption(dwrOption));
//			}
			var imgUrl = "<img src='"+App.ctx+"/scripts/widgets/jquery-ui/extend/images/icon-question.gif'/>";
			$("<div>").attr('title',$.jgrid.nav.alertcap).html(imgUrl+" "+$.jgrid.del.msg).dialog({
				modal:true,
				height:200,
				resizable:false,
				show:$.ui.effects.dialog.show,
				hide:$.ui.effects.dialog.hide,
				buttons:[
				    {"text":$.jgrid.del.bSubmit,
					"click":function(){
						$(grid).jqGrid("deleteSelectRow",grid,editData);
						$(this).dialog("close");
					}},
					{"text":$.jgrid.del.bCancel,
					"click":function(){
						$(this).dialog("close");
					}}
				]
			});
		},
		deleteSelectRow:function(grid,editData){
			var _this = this;
			if(editData.length < 1)return;
			var dwrOption = {
				callback:function(result){
					//5.删除后方法
					if($.isFunction(grid.p.afterDelete)){
						grid.p.afterDelete.call(grid,result);
					}else{
						//内置删除成功提示
						$("#"+grid.p.id+"MessageDialog").html($.jgrid.success.del)
							.dialog("option","title", $.jgrid.initMessageTag.deleteSuccessTag)
							.dialog("open");
					}
					//6.重载数据
					_this.jqGrid("reloadGrid");
					//7.清空编辑区
					$(grid.p.editFormSelector).trigger("reset");
				}
			}
			eval(grid.p.serviceName)[grid.p.serviceMethodName](editData,$.DwrUtils.proDwrOption(dwrOption));
		}
	});
})(jQuery);